#-*-coding:UTF-8 -*-
'''
Created on 2013-6-7

@author: hanjiewu
'''
#元类用于改变类的默认行为和创建方式

class WrapMe(object):
    def __init__(self, obj):
        self.__data = obj
    def get(self):
        return self.__data
    def __repr__(self, *args, **kwargs):
        return 'self.__data'
    def __str__(self, *args, **kwargs):
        return str(self.__data)
    #为__getattr__仅当实例不能在__dict__或类dict、祖先中找到的时候才会触发
    def __getattr__(self, name):
        return getattr(self.__data, name)
wrappedComplex = WrapMe(3.5 + 4.2j)

print wrappedComplex
print wrappedComplex.real

class SlottedClass(object):
    #只有在__slots__中有的名称才能为实例添加属性
    __slots__ = ('foo', 'bar')
c = SlottedClass()
c.foo = 42
#c.xxx ='dont'

import types
class CC:
    pass
class C(object):
    pass
print type(C)
print type(CC)

print types.ClassType


